

int minLength(char *s)
{
    int slow = 0;
    int fast = 1;
    char *temp = s;
    while (fast < strlen(s))
    {
        while (s[fast] != '\0' && slow >= 0 && (s[fast] == 'B' && s[slow] == 'A' || s[fast] == 'D' && s[slow] == 'C'))
        {
            fast++;
            slow--;
        }
        if (s[fast] != '\0')
        {
            slow++;
            s[slow] = s[fast];
            fast++;
        }
    }
    return slow + 1;
}